import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
//导入字体图标
import './assets/fonts/iconfont.css'
//导入全局样式表
import './assets/css/global.css'

//导入NProgress包对应的JS和CSS
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import axios from 'axios'
//配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//axios请求拦截
//在request拦截器中，展示进度条NProgress.start()
axios.interceptors.request.use(config => {
  NProgress.start()
  //为请求头对象，添加Token验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem("token");
  return config;
})
//在response拦截器中，隐藏进度条NProgress.done()
axios.interceptors.response.use(config => {
  NProgress.done()
  return config;
})
Vue.prototype.$http = axios

import ZkTable from 'vue-table-with-tree-grid'

Vue.component("tree-table", ZkTable)

import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)

Vue.filter("dataFormat",function(val){
  const dateVal = new Date(val);
  const fullYear = dateVal.getFullYear();
  const month = (dateVal.getMonth() + 1 + "").padStart(2,"0");
  const day = (dateVal.getDate() + "").padStart(2,"0");
  const hh = (dateVal.getHours() + "").padStart(2,"0");
  const mm = (dateVal.getMinutes() + "").padStart(2,"0");
  const ss = (dateVal.getSeconds() + "").padStart(2,"0");
  return `${fullYear}-${month}-${day} ${hh}:${mm}:${ss}`;
})

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
